// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   excel_three.java

package include.excel_export;


public class excel_three
{

	private String dbase;
	private String tableName;
	private String timea;
	private String timeb;
	private String idNumber;
	private String keyword;
	private String fieldName;
	private String fieldName1;
	private String fieldName2;
	private String fieldName3[];
	private String realname;
	private String condition;
	private String queue;
	private String tagq;
	private String sql;
	private String sql7;

	public excel_three()
	{
		dbase = "";
		tableName = "";
		timea = "";
		timeb = "";
		idNumber = "";
		keyword = "";
		fieldName = "";
		fieldName1 = "";
		fieldName2 = "";
		fieldName3 = new String[1000];
		realname = "";
		condition = "";
		queue = "";
		tagq = "";
		sql = "";
		sql7 = "";
	}

	public String query(String dbase, String tName, String uTimea, String uTimeb, String uIdNumber, String uKeyword, String fName1, 
			String fName2, String fName3[], String uCondition, String uQueue)
	{
		this.dbase = dbase;
		tableName = tName;
		timea = uTimea;
		timeb = uTimeb;
		idNumber = uIdNumber;
		keyword = uKeyword;
		fieldName1 = fName1;
		fieldName2 = fName2;
		fieldName3 = fName3;
		condition = uCondition;
		queue = uQueue;
		try
		{
			if (!timeb.equals(""))
				timeb = (new StringBuilder(String.valueOf(timeb.substring(0, 10)))).append(" 23:59:59").toString();
			if (timea.equals("") && timeb.equals("") && idNumber.equals("") && keyword.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(condition).append(" ").append(queue).toString();
			else
			if (!idNumber.equals("") && keyword.equals("") && timea.equals("") && timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName2).append("='").append(idNumber).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (idNumber.equals("") && keyword.equals("") && !timea.equals("") && timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append(">='").append(timea).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (idNumber.equals("") && keyword.equals("") && timea.equals("") && !timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (idNumber.equals("") && !keyword.equals("") && timea.equals("") && timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(condition).append(" ").append(queue).toString();
			} else
			if (idNumber.equals("") && keyword.equals("") && !timea.equals("") && !timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName1).append(">='").append(timea).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!idNumber.equals("") && keyword.equals("") && !timea.equals("") && timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(fieldName2).append("='").append(idNumber).append("' and ").append(fieldName1).append(">='").append(timea).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!idNumber.equals("") && keyword.equals("") && timea.equals("") && !timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(fieldName2).append("='").append(idNumber).append("' and ").append(fieldName1).append("<='").append(timeb).append("') and ").append(condition).append(" ").append(queue).toString();
			else
			if (!idNumber.equals("") && !keyword.equals("") && timea.equals("") && timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName2).append("='").append(idNumber).append("' and (").append(key).append(") and ").append(condition).append(" ").append(queue).toString();
			} else
			if (idNumber.equals("") && !keyword.equals("") && !timea.equals("") && timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(fieldName1).append(">='").append(timea).append("' and ").append(condition).append(" ").append(queue).toString();
			} else
			if (idNumber.equals("") && !keyword.equals("") && timea.equals("") && !timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(condition).append(" ").append(queue).toString();
			} else
			if (!idNumber.equals("") && !keyword.equals("") && !timea.equals("") && timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName2).append("='").append(idNumber).append("' and ").append(condition).append(" ").append(queue).toString();
			} else
			if (!idNumber.equals("") && !keyword.equals("") && timea.equals("") && !timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(idNumber).append("' and ").append(condition).append(" ").append(queue).toString();
			} else
			if (idNumber.equals("") && !keyword.equals("") && !timea.equals("") && !timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(condition).append(" ").append(queue).toString();
			} else
			if (!idNumber.equals("") && keyword.equals("") && !timea.equals("") && !timeb.equals(""))
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName2).append("='").append(idNumber).append("' and ").append(condition).append(" ").append(queue).toString();
			else
			if (!idNumber.equals("") && !keyword.equals("") && !timea.equals("") && !timeb.equals(""))
			{
				String key = "";
				int m = 0;
				for (int i = 0; i < fieldName3.length - 1; i++)
				{
					key = (new StringBuilder(String.valueOf(key))).append(fieldName3[i]).append(" like ").append("'%").append(keyword).append("%'").append(" or ").toString();
					m++;
				}

				key = (new StringBuilder(String.valueOf(key))).append(fieldName3[m]).append(" like ").append("'%").append(keyword).append("%'").toString();
				sql = (new StringBuilder("select * from ")).append(tableName).append(" where (").append(key).append(") and ").append(fieldName1).append(">='").append(timea).append("' and ").append(fieldName1).append("<='").append(timeb).append("' and ").append(fieldName2).append("='").append(idNumber).append("' and ").append(condition).append(" ").append(queue).toString();
			}
		}
		catch (Exception exception) { }
		return sql;
	}
}
